from base.base_action import BaseAction
from selenium.webdriver.common.by import By


# 账号部门页面,增删改查操作
class AccountDM(BaseAction):

    # 新增账号按钮
    add_user = By.XPATH, "//span[text()='新增账号']"

    # 用户账号
    user_account = By.XPATH, "//input[@placeholder='请输入用户账号']"

    # 姓名
    username = By.XPATH, "//input[@placeholder='请输入姓名']"

    # 部门下拉框
    dept_drop_down_box = By.XPATH, "//input[@placeholder='请选择部门']"

    # 选择部门
    select_dept = By.XPATH, "/html/body/div[2]/div[1]/div[1]/div[1]/ul/li/label/span[1]/span"

    # 点击空白区域
    blank_area = By.XPATH,  "//span[text()='基本信息']"

    # 保存按钮
    preservation = By.XPATH, "//span[text()='保存']"

    # 编辑按钮
    edit_btn = "document.getElementsByClassName('operate-style')[0].click();"

    # 姓名搜索框
    name_search = By.XPATH, "//input[@placeholder='搜索账号/姓名']"

    # 状态筛选框
    status_filter = By.XPATH, "//input[@placeholder='状态']"

    # 筛选框选择启用
    enable = By.XPATH, "/html/body/div[2]/div[1]/div[1]/ul/li[1]/span"

    # 筛选框选择禁用
    disable = By.XPATH, "/html/body/div[2]/div[1]/div[1]/ul/li[2]/span"

    # 禁用按钮
    disable_button = "document.getElementsByClassName('operate-style')[2].click();"

    # "禁用"该用户的"确定"按钮
    determine_btn = By.XPATH, "/html/body/div[2]/div/div[3]/button[2]/span"

    # 点击新增
    def click_add_user(self):
        return self.click(self.add_user)

    # 输入用户账号
    def input_user_account(self, content):
        return self.input(self.user_account, content)

    # 输入用户名
    def input_username(self, content):
        return self.input(self.username, content)

    # 点击部门下拉框
    def click_dept_drop_down_box(self):
        return self.click(self.dept_drop_down_box)

    # 点击保存
    def click_preservation(self):
        return self.click(self.preservation)

    # 点击编辑
    def click_edit_btn(self):
        return self.execute_js(self.edit_btn)

    # 清空用户账号内容
    def clear_user_account(self):
        return self.clear(self.user_account)

    # 清空姓名内容
    def clear_username(self):
        return self.clear(self.username)

    # 通过账号查询
    def input_account(self, content):
        self.input(self.name_search, content)
        return self.click_keys_enter(self.name_search)

    # 点击状态筛选
    def click_status_filter(self):
        return self.click(self.status_filter)

    # 点击启用进行筛选
    def click_enable(self):
        return self.click(self.enable)

    # 点击禁用进行筛选
    def click_disable(self):
        return self.click(self.disable)

    # 点击禁用按钮
    def click_more_disable_btn(self):
        return self.execute_js(self.disable_button)

    # 点击确定按钮
    def click_determine_btn(self):
        return self.click(self.determine_btn)




